# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.ArtifactRegistry.V1.Model.GoogleDevtoolsArtifactregistryV1Rule do
  @moduledoc """
  A rule defines the deny or allow action of the operation it applies to and the conditions required for the rule to apply. You can set one rule for an entire repository and one rule for each package within.

  ## Attributes

  *   `action` (*type:* `String.t`, *default:* `nil`) - The action this rule takes.
  *   `condition` (*type:* `GoogleApi.ArtifactRegistry.V1.Model.Expr.t`, *default:* `nil`) - Optional. A CEL expression for conditions that must be met in order for the rule to apply. If not provided, the rule matches all objects.
  *   `name` (*type:* `String.t`, *default:* `nil`) - The name of the rule, for example: `projects/p1/locations/us-central1/repositories/repo1/rules/rule1`.
  *   `operation` (*type:* `String.t`, *default:* `nil`) - 
  *   `packageId` (*type:* `String.t`, *default:* `nil`) - The package ID the rule applies to. If empty, this rule applies to all packages inside the repository.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :action => String.t() | nil,
          :condition => GoogleApi.ArtifactRegistry.V1.Model.Expr.t() | nil,
          :name => String.t() | nil,
          :operation => String.t() | nil,
          :packageId => String.t() | nil
        }

  field(:action)
  field(:condition, as: GoogleApi.ArtifactRegistry.V1.Model.Expr)
  field(:name)
  field(:operation)
  field(:packageId)
end

defimpl Poison.Decoder,
  for: GoogleApi.ArtifactRegistry.V1.Model.GoogleDevtoolsArtifactregistryV1Rule do
  def decode(value, options) do
    GoogleApi.ArtifactRegistry.V1.Model.GoogleDevtoolsArtifactregistryV1Rule.decode(
      value,
      options
    )
  end
end

defimpl Poison.Encoder,
  for: GoogleApi.ArtifactRegistry.V1.Model.GoogleDevtoolsArtifactregistryV1Rule do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
